package com.snake.springboot.authority.service.mq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.snake.common.utils.RandomUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * <p>看板MQ推送消息
 * 类 {@code MqBoardSender}  <br> .
 * 创建时间：2024/10/14 9:31
 * @author yxt
 * @see
 */
@Component
public class MqSender {
    @Value("${log.trace.key:zTraceId}")
    private String keyTraceId;
    private Logger log= LoggerFactory.getLogger(MqSender.class);

    @Autowired
    private RabbitTemplate rabbitTemplate;
    public void sendMsg(String exchange,String routingKey,String msg){
        try {
            MDC.put(keyTraceId, RandomUtils.charNum(6));
            log.info("{}发送数据消息:{}", routingKey, msg);
            rabbitTemplate.convertAndSend(exchange,routingKey,  msg);
        }catch (Exception e){}

    }


}
